<%--
  Created by IntelliJ IDEA.
  User: guoshuai
  Date: 2016/11/17
  Time: 11:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<section class="wrapper">
    <div class="row">
        <div class="col-lg-12">
            <section class="panel">
                <header class="panel-heading">
                    角色管理
                    <button type="button" class="btn btn-info pull-right"
                            onclick="oceanModal.openDefault('system/role/item')">新增角色
                    </button>
                </header>
                <div class="panel-body">
                    <div class="row">
                        <div class="col-lg-6">
                            <table class="table table-striped table-bordered sortable">
                                <thead>
                                <tr>
                                    <th>角色名称</th>
                                    <th>角色编码</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody id="role-list-body">
                                <tr>

                                </tr>
                                </tbody>
                            </table>
                        </div>

                        <div class="col-lg-6">

                        </div>
                    </div>
                </div>
            </section>
        </div>
    </div>
</section>

<script type="text/template" id="role-list-template">
    <@ _.each(items, function (item) { @>
    <tr>
        <td><@= item.name @></td>
        <td><@= item.code @></td>
        <td>
            <button class="btn btn-primary btn-xs"
                    onclick="oceanModal.openDefault('system/role/item?id=<@= item.id @>')">
                <i class="icon-pencil"></i>
            </button>
            <button class="btn btn-success btn-xs"
                    onclick="oceanModal.openDefault('system/role/menu?id=<@= item.id @>')">菜单权限
            </button>
            <button class="btn btn-info btn-xs"
                    onclick="oceanModal.openDefault('system/role/operation?id=<@= item.id @>')">数据权限
            </button>
            <button class="btn btn-danger btn-xs"
                    onclick="confirmDialog.drop('<@= item.id @>','<@= item.name @>', 'com.ocean.core.entity.Role')">
                <i class="icon-trash "></i>
            </button>
        </td>
    </tr>
    <@ }); @>
</script>
<script type="application/javascript">
    function load() {
        WaitingDialog.show();
        $.post("resources/role/list", {}, function (data) {
            WaitingDialog.dismiss();
            if (data == null) {
                return;
            }
            var tmpl = _.template($('#role-list-template').html());
            $('#role-list-body').html(tmpl({items: data}));
        });
    }
    load();
</script>
